<?php

/**
 * @author MadPitbull
 * @copyright 2011
 */

	class PageLoadingTime{
		
		private $time;
		private $initTime;
		private $finTime;
		private $totalTime;
/*------------------------------------------------------------------------------------------------------*/			
		/**
		 * PageLoadingTime::__construct()
		 * Starts the timer. 
		 * @return null
		 */
		public function __construct() {
			$this->initPageLoadingTime();
		}
		
/*------------------------------------------------------------------------------------------------------*/			
		private function initPageLoadingTime() {
			$this->time = microtime();
			$this->time = explode(" ", $this->time);
			$this->time = $this->time[1] + $this->time[0];
			$this->initTime = $this->time;
		}
		
		
/*------------------------------------------------------------------------------------------------------*/			
		/**
		 * PageLoadingTime::getPageLoadingTime()
		 * Returns a float var with the page loading time in micro seconds.
		 * @return float
		 */
		public function getPageLoadingTime() {
			$this->time =  microtime();
			$this->time = explode(" ", $this->time);
			$this->time = $this->time[1] + $this->time[0];
			$this->finTime = $this->time;
			$this->totalTime = ($this->finTime - $this->initTime);
			
			return $this->totalTime;
		}
/*------------------------------------------------------------------------------------------------------*/			
		
	}

?>